Let's dive into Cloud
Endpoints for REST APIs. This diagram illustrates the
high level steps to make your API backend available
as a Cloud Endpoints API. After you develop your
REST API backend, create an API configuration file that describes your
Cloud Endpoints API. Deploy the API
configuration by using the gcloud service
management deploy command. The gcloud command returns the service configuration
ID and service name. Specify the service
configuration ID and service name in your APIs
backend configuration files, such as the app.yaml file for App Engine flexible
environment deployments. Finally, deploy the API backend. Create an API configuration file that describes your
Cloud Endpoints API. The API configuration
is a YAML file that describes the API using
the OpenAPI specification. The OpenAPI specification
and its extensions enable you to describe the surface of the API and security
definitions. You can specify security
definitions for user authentication and service-to-service
authentication. Various tools are
available to help you create and manage your
OpenAPI specification. For more information, see documentation on
the Swagger Editor, the Swagger Tools
and integrations, and OpenAPI Swagger Resource
List for API developers. When you deploy the
API configuration, it is registered with
the service management API and shared with the
Extensible Service Proxy. Service management
uses the host value in your deployment
configuration file to create a new Cloud
Endpoints service, with the name and the
format shown here. That is, your API name.endpoints.your
project ID.cloud.goog. This API service name is created if it doesn't already
exist and then Cloud Endpoints
configures the service according to your OpenAPI
configuration file. Cloud Endpoints uses DNS compatible names to
uniquely identify services. Because projects in
Google Cloud are guaranteed to have a
globally unique name. You can use your
project name to create a unique API service
name such as quizapi.endpoints.myprojectid.cloud.goog. You can also map your own
DNS name to your API. The Extensible Service Proxy
is an engine based proxy, that runs in front
of the API backend and injects Cloud
Endpoints functionalities, such as authentication, monitoring, and logging. The proxy uses techniques
such as heavy caching in asynchronous calls to remain lightweight and
highly performing. At runtime, Cloud Endpoints can receive calls
from any source, such as mobile applications, web applications,
and other services. The calls are load balanced and routed to the Extensible
Service Proxy. The Extensible Service
Proxy works with a Service Control API
to check the request against the API
configuration and verify that the request can be passed through to the backend. If the request
authenticates successfully, the Extensible Service Proxy passes it on to the API backend. The Service Control API logs information about
incoming requests. These log messages
and metrics can be viewed by using
the Cloud Console. With Cloud Endpoints API, you can authenticate
users who are attempting to invoke
your front end APIs. Cloud Endpoints supports user authentication
with Firebase, off to zero, Google
authentication, and other custom
authentication methods. After the user signs in, the authentication
providers send a signed JSON Web Token or
JWT to Cloud Endpoints. Cloud Endpoints checks
the JWT is signed by the provider that you specified in your
API configuration. For service-to-service
authentication, create a service account. Use a Google ID token
to sign the request. To restrict access to
your Cloud Endpoints API, you can assign Identity in Access Management roles
to specific users. You can grant access to a specific API or to the
entire Cloud project. To give users the ability
to enable your service in their own Cloud project
and invoke its APIs, assign the service
consumer role to them. This is the most
common use case. You can assign the service
controller, viewer, editor or owner
roles to give users greater permissions to view and manage service
configurations and projects. You might make small
changes, bug fixes, and performance enhancements
to your API backend. These changes are usually
backwards compatible. In such cases, it's a good practice to increment the
version attribute in the Cloud Endpoints API
configuration and then redeploy the API configuration
in the API backend. In the example shown, we've increased the
version number from 1.1-1.2 because this is a
backwards compatible change. If you make changes
that are not backwards compatible and will break functionality for consumers of your API to point
two versions of your Cloud Endpoints
API by creating a separate API configuration
for each version. The gcloud service management
deploy command will return a different service configuration ID
for each version. Update the API backend
configuration of each version with the corresponding service
configuration ID. In the example shown, we have different API
configurations for version 1 of the API and
version 2 of the API. You can also delete versions of your API when they're
no longer in use. Make sure to announce your
deprecation and phase out plans to the consumers of
the API well in advance. This will give them
time to evaluate and migrate to newer
versions of your API. When developing and deploying APIs you will have
separate environments for developing and staging
limited releases such as private alphas
and for production. You can create
separate projects for each environment and deploy
a Cloud Endpoints API and backend with separate
endpoints for your consumers for example, developers can run their unit tests against the
development environment. You can run integration tests against the staging endpoint. A separate project
for private alphas provides a higher degree of isolation from
other environments. In the Cloud
Endpoints dashboard, you can see metrics
related to requests, 4XX, and 5XX errors,
and latency. You can also view logs
in Cloud logging to see detailed information about
requests to each API. You can use Cloud
Endpoints portal to create developer portals, websites that users of your Cloud Endpoints APIs can access to explore
and test your APIs. On your portals, developers who are using your APIs
in their own code can find the Smart Docs API
reference documentation for your APIs. Smart Docs uses the
OpenAPI document that Cloud Endpoints
frameworks creates to generate API
reference documentation. Smart Docs includes a
try this API panel, so developers can interact with your APIs without leaving
the documentation. Let's explore some
of the reasons why you might choose one
platform over another. First let's look at some of the reasons why you might
choose Cloud Endpoints. Cloud Endpoints is a Google
Cloud API management solution that gives you full control
over your API Gateway, because it is deployed, configured, and managed by you. It supports gRPC, a modern, open source, high performance,
remote procedure call framework that can run
in any environment. On the negative side, Cloud Endpoints
forces you to manage the entire lifecycle of the Engine X envoy
based gateway, including security updates, traffic migration, and
managing the compute platform. You also pay for
Compute Engine VMs. In addition, proxied
services outside Google Cloud require a service
proxy in Google Cloud. Now let's look at some
of the reasons why you might choose API gateway. Google Cloud's API Gateway
enables you to develop, deploy, secure, and manage your APIs using
a fully managed gateway. You can provide secure access to your backend services through a well-defined REST API that is consistent across all
of your services, regardless of service
implementation. Why might you
choose API Gateway? API Gateway is fully
managed by Google, which allows you to
take advantage of all the operational benefits
of server less technology. Google handles
management operations like security and configuration updates or providing you flexible deployment
and scalability. API Gateway is often a
better solution when using serverless app platforms
like Cloud Functions, Cloud Run, and App Engine. It's relatively
inexpensive to run as you don't pay for and
managed compute VMs. API Gateway also supports gRPC. However, since API Gateway
is managed by Google, it allows less control
than Cloud Endpoints. Also like Cloud Endpoints, proxied services
outside Google Cloud require a service
proxy in Google Cloud. Now let's look at some of
the reasons why you might choose the Apigee API platform. Google Cloud's Apigee
API platform is a fully featured platform for developing and managing APIs. By fronting services
with a proxy layer, Apigee provides an
abstraction or facade for your backend service APIs allowing you to
easily add security, rate limiting, quota,
analytics and more. Apigee is made to proxy APIs anywhere not just
in Google Cloud. In addition to the
basic API Gateway features found in
Cloud Endpoints and API Gateway such as API
key and JWT token checks, Apigee provides a
developer portal, API products, custom call outs, payload transformation,
content based security, the ability to combine
multiple services, and many more features. Apigee is more expensive to use than Cloud Endpoints
or API Gateway. It is typically not appropriate for very
simple API use cases. Here are some pointers
to more information. The API design guide
is a great resource to help you learn how to
design APIs in general. Also, check out this talk from the Google Cloud
next conference.